home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: Ctors & member methods ?
- Date: 8 Feb 1996 21:06:41 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4fdol1$7il@dawn.mmm.com>
- References: <3100187d.5776685@ixnews7.ix.netcom.com> <4fcuqb$ms7@tic.sm.dsi.unimi.it>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- ~ZIO BUDDA~ (moreld@dsi.unimi.it) wrote:
- > n4jvp (n4jvp@ix.netcom.com) wrote:
- > > I have a question concerning ctors. Can a ctor call a member
- > > method?
-
- [example elided]
-
- > I say Yes... By this way U call a function of Class Foo from another Function of class Foo.
-
- But be aware that the "virtualness" of member functions is not there until
- the object is fully constructed. Consider:
- class Base
- {
- public:
- Base();
- virtual void f();
- };
- class Derived : public Base
- {
- public:
- Derived();
- virtual void f();
- }
- Base::Base()
- {
- f(); // never calls Derived::f()
- }
-
- The call to f() in Base::Base() will call Base::f() even if the object
- being constructed will ultimately be a Derived.
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-